/*
 * ListenetTurboNoteImpl.java
 *
 * Created on 02/07/2007, 10:50:59
 *
 */
package br.com.grillo.jturbonote;

import java.io.IOException;
import java.net.InetAddress;
import org.apache.commons.io.IOUtils;

/**
 *
 * @author grillo
 */
public class ListenerJTurboNoteImpl implements ListenerJTurboNote {

    public ListenerJTurboNoteImpl() {
    }

    @Override
    public synchronized void onNewNote(final InetAddress source, final byte[] input) {
        Thread t = new Thread() {

            @Override
            public void run() {
                try {
                    System.out.println("RECEIVE {" + IOUtils.toString(input, "ISO-8859-1") + "}");
                } catch (IOException ioEx) {
                }
                FrameNota frmNota = new FrameNota();
                frmNota.setNota(new Nota(input, source));
                frmNota.setVisible(true);
                MenuSistema.getInstance().addNota(frmNota);
            }
        };
        t.start();
    }
}
